package com.lixueju.security.box.core.properties;

import lombok.Data;

import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * 微信的配置信息
 *
 * @author lixueju
 * @since 2019/10/8 13:16
 **/
@Data
public class WeixinProperties {

    private String weixinAccessTokenKeyForRedis = "security_box_weixin_access_token";

    /**
     * 微信应用账号信息
     */
    private WeixinAppProperties[] apps = {};

    /**
     * 获取对应的app账号信息
     */
    public WeixinAppProperties getAppByName(String appName) {
        return Arrays.stream(apps).collect(Collectors.toMap(WeixinAppProperties::getName, a -> a)).get(appName);
    }
}
